package com.atguigu.gmall.product.api;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.product.*;
import com.atguigu.gmall.product.service.ManagerService;
import com.atguigu.gmall.product.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.List;
import java.util.Map;

/**
 * @Author: lx
 * @Time: 15:27
 * @Description:
 */
@RestController
@RequestMapping("/api/product")
public class ProductApiController {

    @Autowired
    private ProductService productService;
    //2：查询一二三级分类

    @GetMapping("/inner/getBaseCategoryView/{category3Id}")
    public BaseCategoryView getBaseCategoryView(@PathVariable Long category3Id) {
        return productService.getBaseCategoryView(category3Id);
    }

    //1：查询SkuInfo对象
    @GetMapping("/inner/getSkuInfo/{skuId}")
    public SkuInfo getSkuInfo(@PathVariable Long skuId) {
        return productService.getSkuInfo(skuId);
    }

    //3：查询价格
    @GetMapping("/inner/getPrice/{skuId}")
    public BigDecimal getPrice(@PathVariable Long skuId) {
        return productService.getPrice(skuId);
    }

    //4:查询当前商品spu对应的所有的销售属性及属性值集合 并 skuid进行选中
    @GetMapping("/inner/getSpuSaleAttrAndChecked/{spuId}/{skuId}")
    public List<SpuSaleAttr> getSpuSaleAttrAndChecked(@PathVariable Long spuId,
                                                      @PathVariable Long skuId) {
        return productService.getSpuSaleAttrAndChecked(spuId, skuId);
    }

    //5: 销售属性值ID的组合 对应 skuId 数据
    @GetMapping("/inner/getSaleAttrValuesBySpu/{spuId}")
    public Map getSaleAttrValuesBySpu(@PathVariable Long spuId) {
        return productService.getSaleAttrValuesBySpu(spuId);
    }

    //查询所有分类视图对象集合
    @GetMapping("/inner/getBaseCategoryViewList")
    public List<BaseCategoryView> getBaseCategoryViewList() {
        return productService.getBaseCategoryViewList();
    }

    //根据ID查询品牌
    @GetMapping("/inner/baseTrademark/{id}")
    public BaseTrademark getBaseTrademark(@PathVariable Long id) {
        return managerService.getBaseTrademark(id);
    }
    @Autowired
    private ManagerService managerService;

    //查询平台属性及属性值 根据skuId
    @GetMapping("/inner/getBaseAttrInfoAndBaseAttrValue/{skuId}")
    public List<SkuAttrValue> getBaseAttrInfoAndBaseAttrValue(@PathVariable Long skuId){
        return productService.getBaseAttrInfoAndBaseAttrValue(skuId);
    }
}
